//index.js
//获取应用实例
const app = getApp()

Page({
    data: {
        content:'',
        isClick:0,
        len:0
    },
    submitInfo:function () {
        var that = this;

        if(that.data.isClick) return;
        that.data.isClick = 1;

        if(!this.data.content){
            wx.showModal({
                title:'提示',
                content:'数据不完整，检查后再提交',
                showCancle:false,
            })
            that.data.isClick = 0;
            return;
        }
        if(this.data.content.length>200){
            wx.showModal({
                title:'提示',
                content:'内容长度太长了，请修改下再提交',
                showCancle:false,
            })
            that.data.isClick = 0;
            return;
        }
        var data = {
            content:that.data.content
        }
        app.util.request({
            url:app.globalRequestUrl + '/telservice',
            method:'GET',
            data:data,
            success:function (res) {
                if(res && res.msg == 'success'){
                    wx.showToast({
                        title:'提交成功，感谢您的反馈！',
                        icon:'success'
                    })
                    setTimeout(function () {
                        wx.switchTab({
                            url:'/pages/my/my'
                        })
                    },2000)
                }
            },
            complete:function () {
                setTimeout(function () {
                    that.data.isClick = 0;
                },1000)
            }
        })
    },
    bindInputContent:function (e) {
        var val = e.detail.value;
        var that = this;
        clearTimeout(this.data.timer)
        this.data.timer = setTimeout(function () {
            that.setData({
                len:val.length
            })
        },100)

        this.data.content = val;
    },
})
